Release 10.1A: OpenEdge Data Management:
SQL Reference


OPEN

Executes a prepared SQL query associated with a cursor and creates a result set composed of the rows that satisfy the query. This set of rows is called the active set.

Syntax

OPEN cursor_name 
  [ USING { [ SQL ] DESCRIPTOR structure_name 
    | :host_variable [ [ INDICATOR ] :ind_variable  ] ,  ...  }   ] ; 

cursor_name

An identifier named in an earlier DECLARE CURSOR statement.

USING [ SQL ] DESCRIPTOR structure_name

Directs the SQL engine to create the result set in storage addressed by the identified SQLDA structure.

USING :host_variable [ [ INDICATOR ] :ind_variable ]

Directs the SQL engine to create the result set in storage addressed by host variables.

Example

/* 
**    5.  Name WHENEVER routine to handle SQLERROR. 
** 
**    6.  DECLARE cursor for the SELECT statement. 
**        NOTE: You must set input parameter values before OPEN CURSOR. 
**        The static query in this program does not have input parameters. 
** 
**    7.  OPEN the cursor. 
**        NOTE: For static statements, if a DECLARE CURSOR 
**              statement contains references to automatic variables, 
**              the OPEN CURSOR statement must be in the same C function. 
** 
**    8.  Name WHENEVER routine to handle NOT FOUND condition. 
*/ 
      
      EXEC SQL WHENEVER SQLERROR GOTO selerr ; 
      EXEC SQL DECLARE stcur CURSOR FOR   
            SELECT InvTransNum, Qty, 
            OrderNum FROM PUB.InventoryTrans ; 
      EXEC SQL OPEN stcur ;       
      EXEC SQL WHENEVER NOT FOUND GOTO seldone ; 

Notes

Authorization

Must have DBA privilege of SELECT privilege on all the tables and views referenced in the SELECT statement associated with the cursor.

Related statements

DECLARE CURSOR, CLOSE, FETCH, positioned UPDATE, positioned DELETE


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095